#include// open transport files #include /* input: noDelayState - true - nodelay // false - normal delay state // // output: if result less that kOTNoError, then the result of // OTOptionManagement call is returned // otherwise, the status value is returned as defined in // OpenTransport.h T_SUCCESS = 0x020, if SUCCESS, then return kOTNoError T_FAILURE = 0x040, T_PARTSUCCESS = 0x100, T_READONLY = 0x200, T_NOTSUPPORT = 0x400 */ OSStatus DoNegotiateNoDelayOption(EndpointRef ep, Boolean noDelayState) { UInt8 buf[kOTFourByteOptionSize]; // define buffer for fourByte // Option size TOption* opt; // option ptr to make items // easier to access TOptMgmt req; OSStatus err; Boolean isAsync = false; opt = (TOption*)buf; // set option ptr to buffer req.opt.buf = buf; req.opt.len = sizeof(buf); req.opt.maxlen = sizeof(buf); // were using ret for the return // result also. req.flags = T_NEGOTIATE; // negotiate for option opt->level = INET_TCP; // dealing with an TCP Level function opt->name = TCP_NODELAY; // define the option to be negotiated opt->len = kOTFourByteOptionSize; opt->status = 0; *(UInt32*)opt->value = noDelayState; // set the desired option level, true // or false if (OTIsSynchronous(ep) == false) // check whether ep sync or not { isAsync = true; // set flag if async OTSetSynchronous(ep); // set endpoint to sync } err = OTOptionManagement(ep, &req, &req); if (isAsync == true) // restore ep state if necessary OTSetAsynchronous(ep); // if no error then check the option status value if (err == kOTNoError) { if (opt->status != T_SUCCESS) // if not T_SUCCESS, return // the status err = opt->status; } // otherwise return kOTNOError return err; }
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help